package com.zw.stock_sell_storage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zw.stock_sell_storage.dto.CustomerDto;
import com.zw.stock_sell_storage.dto.MyPageDto;
import com.zw.stock_sell_storage.service.ICustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/customer")
public class CustomerController {
    @Autowired
    ICustomerService iCustomerService;

    @RequestMapping("/queryCustomerList")
    public Page<CustomerDto> queryCustomerList(@RequestBody MyPageDto<CustomerDto> myPageDto){
        return iCustomerService.queryCustomerList(myPageDto);
    }

    @RequestMapping("/queryCustomerOne")
    public CustomerDto queryCustomerOne(int customerId){
        return iCustomerService.queryCustomerOne(customerId);
    }

    @RequestMapping("/updateCustomer")
    public boolean updateCustomer(@RequestBody CustomerDto customerDto){
        return iCustomerService.updateCustomer(customerDto);
    }

    @RequestMapping("/addCustomer")
    public boolean addCustomer(@RequestBody CustomerDto customerDto){
        return iCustomerService.addCustomer(customerDto);
    }

    @RequestMapping("/queryAllCustomerList")
    public List<CustomerDto> queryAllCustomerList(){
        return iCustomerService.queryAllCustomerList();
    }
}
